package com.pi.fssm.base.dao;

import java.util.List;

import com.pi.fssm.base.dao.common.Criteria;
import com.pi.fssm.base.dao.common.Pager;

/**
 * 
 * Description:
 * dao基类，包括基本数据库操作方法
 * BaseDao.java Create on 2013-4-18 下午9:20:44 
 * @author held
 * @version 1.0
 * Copyright (c) 2013 held,Inc. All Rights Reserved.
 */
public interface BaseDao<T, PK> {
	
	
	public T get(PK id);

	public List<T> get(List<PK> ids);
	
	public T get(PK id, boolean isForUpdate);

	public List<T> get(List<PK> ids, boolean isForUpdate);
	
	public List<T> getAll();
	
	public int getTotalCount();
	
	public int getTotalCountBy(Criteria criteria);
	
	public int insert(T entity);

	public int insert(List<T> entitys);

	public int update(T entity);

	public int updateBy(T entity, Criteria criteria); //update: 根据 entity的主键,如果entity的主键有多个, 则需要自己来实现, 组合主键的表Mapper不会有update
	
	public int update(List<T> entitys);
	
	public int delete(List<PK> ids);
	
	public int deleteBy(Criteria criteria);
	
	public int delete(PK id); //delete: 根据 entity的主键,如果entity的主键有多个, 则需要自己来实现, 组合主键的表Mapper不会有delete
	
	public Pager<T> getByPager(Pager<T> pager);
	
	public T getOneByPager(Pager<T> pager);

	public double getSumBy(Criteria criteria);

	public Pager<T> getByCustomedPager(Pager<T> pager, String findSqlMapperName, String countSqlMapperName);
	
	public void clearCache();//刷新缓存, 本线程被修改
}